package com.javawork.juc.jvm;

import org.openjdk.jol.info.ClassLayout;

/**
 * 1. 默认配置，启动了压缩指针，-XX：+UseCompressedClassPointers
 *      12+4（对齐填充）=一个对象16字节
 * 2. 手动关闭压缩指针：配置VM Option  -XX:-UseCompressedClassPointers
 * @author zhangxiaolu
 * @since 2023-02-14 23:40
 */
public class JOLDemo {

    public static void main(String[] args) {
        Object o = new Object();
        System.out.println(ClassLayout.parseInstance(o).toPrintable());
//        System.out.println(VM.current().details());
        Customer customer = new Customer();
        System.out.println(ClassLayout.parseInstance(customer).toPrintable());

    }
}

class Customer {
    // 1.只有对象头，没有其他任何实例数据
    // 2.int + boolean 24bit,对齐填充7bit（压缩指针）
    int id;
    boolean flag = false;
}